package com.homeparking.manage.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.homeparking.common.annotation.Log;
import com.homeparking.common.core.controller.BaseController;
import com.homeparking.common.core.domain.AjaxResult;
import com.homeparking.common.enums.BusinessType;
import com.homeparking.manage.domain.JoinUs;
import com.homeparking.manage.service.IJoinUsService;
import com.homeparking.common.utils.poi.ExcelUtil;
import com.homeparking.common.core.page.TableDataInfo;

/**
 * 合伙人留言Controller
 * 
 * @author liuyangyang
 * @date 2025-05-09
 */
@RestController
@RequestMapping("/manage/joinus")
public class JoinUsController extends BaseController
{
    @Autowired
    private IJoinUsService joinUsService;

    /**
     * 查询合伙人留言列表
     */
    @PreAuthorize("@ss.hasPermi('manage:joinus:list')")
    @GetMapping("/list")
    public TableDataInfo list(JoinUs joinUs)
    {
        startPage();
        List<JoinUs> list = joinUsService.selectJoinUsList(joinUs);
        return getDataTable(list);
    }

    /**
     * 导出合伙人留言列表
     */
    @PreAuthorize("@ss.hasPermi('manage:joinus:export')")
    @Log(title = "合伙人留言", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, JoinUs joinUs)
    {
        List<JoinUs> list = joinUsService.selectJoinUsList(joinUs);
        ExcelUtil<JoinUs> util = new ExcelUtil<JoinUs>(JoinUs.class);
        util.exportExcel(response, list, "合伙人留言数据");
    }

    /**
     * 获取合伙人留言详细信息
     */
    @PreAuthorize("@ss.hasPermi('manage:joinus:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") String id)
    {
        return success(joinUsService.selectJoinUsById(id));
    }

    /**
     * 新增合伙人留言
     */
    @Log(title = "合伙人留言", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody JoinUs joinUs)
    {
        return toAjax(joinUsService.insertJoinUs(joinUs));
    }

    /**
     * 修改合伙人留言
     */
    @PreAuthorize("@ss.hasPermi('manage:joinus:edit')")
    @Log(title = "合伙人留言", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody JoinUs joinUs)
    {
        return toAjax(joinUsService.updateJoinUs(joinUs));
    }

    /**
     * 删除合伙人留言
     */
    @PreAuthorize("@ss.hasPermi('manage:joinus:remove')")
    @Log(title = "合伙人留言", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable String[] ids)
    {
        return toAjax(joinUsService.deleteJoinUsByIds(ids));
    }
}
